<?php
/*****************************
* PHPwork官方网址： ruanjiesoft.com
* PHPwork应用官方QQ群： 317075601
* PHPwork应用开发者QQ： 1980572700
* 不得使用本软件用于非法用途，不得违反国家法律。
*************************************/

namespace application\cms\controller;

require 'base.php';

class Goods extends Base{

    //商品
    function index(){   
        
    } 

    //商品分类 - 商品列表
    function goods_list(){   

        $sort_id = intval($_GET['sort_id']);
        
        $sql="select * from ".tablename('rj_cms_goods_sort')." where status=1 and sort_id=$sort_id ";
        $goods_sort=$GLOBALS['db']->query($sql)->fetch();
        
        $sql="select * from ".tablename('rj_cms_goods')." where status=1 and sort_id=$sort_id order by update_time desc,id desc ";
        $page= \library\deep\Page::new_instance();   // 分页
        $sql=$page->getPageSQL( $sql , 20 );
        $goods=$GLOBALS['db']->query($sql);
		
        $this->config['title'] = $goods_sort['sort_name']; // 网页标题

		require view('default/' . $goods_sort['tpl_name'] ); //goods_list.tpl.php

    } 

    //商品详细
    function goods_detail(){   
        
        if(isset($_GET['id']) && $_GET['id']!=''){
            $id = intval( $_GET['id'] );
            $sql="select * from ".tablename('rj_cms_goods')." where status=1 and id = $id  ";
            $goods=$GLOBALS['db']->query($sql)->fetch();
			
			$this->config['title'] = $goods['goods_name']; // 网页标题
			
        }else{
            header('Location:'.url([ _MODULE_NAME_ ,'index','index']));
            exit;
        }

		require view('default/' . $goods['tpl_name'] ); //goods_detail.tpl.php
		
    } 

}
